package com.example.demo.database.model;

/**
 * @ClassName: Entity
 * @Author : sz
 * @Date :2024/2/29  10:39
 * @Description: TODO
 * @Version :1.0
 */

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import java.time.LocalDateTime;

public class Entity<T> {
    public static final String ID_FIELD = "id";
    public static final String CREATE_BY = "createBy";
    public static final String CREATE_BY_FIELD = "create_by";
    public static final String CREATE_TIME = "createTime";
    public static final String CREATE_TIME_FIELD = "create_time";
    public static final String UPDATED_BY = "updateBy";
    public static final String UPDATED_BY_FIELD = "update_by";
    public static final String UPDATED_TIME = "updateTime";
    public static final String UPDATED_TIME_FIELD = "update_time";
    @TableId(
            value = "id",
            type = IdType.INPUT
    )
    @ApiModelProperty("主键id")
    protected T id;
    @TableField(
            value = "create_by",
            fill = FieldFill.INSERT
    )
    @ApiModelProperty("创建人")
    protected T createBy;
    @TableField(
            value = "create_time",
            fill = FieldFill.INSERT
    )
    @ApiModelProperty("创建时间")
    @JsonFormat(
            pattern = "yyyy-MM-dd HH:mm:ss"
    )
    protected LocalDateTime createTime;
    @TableField(
            value = "update_by",
            fill = FieldFill.INSERT_UPDATE
    )
    @ApiModelProperty("更新人")
    protected T updateBy;
    @TableField(
            value = "update_time",
            fill = FieldFill.INSERT_UPDATE
    )
    @ApiModelProperty("更新时间")
    @JsonFormat(
            pattern = "yyyy-MM-dd HH:mm:ss"
    )
    protected LocalDateTime updateTime;
    @TableLogic(
            value = "0",
            delval = "1"
    )
    @ApiModelProperty("删除标志")
    private Integer delFlag;

    public Entity() {
    }

    public Entity(T id, LocalDateTime createTime, T createBy, LocalDateTime updateTime, T updateBy, Integer delFlag) {
        this.id = id;
        this.createBy = createBy;
        this.createTime = createTime;
        this.updateBy = updateBy;
        this.updateTime = updateTime;
        this.delFlag = delFlag;
    }

    public T getId() {
        return this.id;
    }

    public T getCreateBy() {
        return this.createBy;
    }

    public LocalDateTime getCreateTime() {
        return this.createTime;
    }

    public T getUpdateBy() {
        return this.updateBy;
    }

    public LocalDateTime getUpdateTime() {
        return this.updateTime;
    }

    public Integer getDelFlag() {
        return this.delFlag;
    }

    public Entity<T> setId(T id) {
        this.id = id;
        return this;
    }

    public Entity<T> setCreateBy(T createBy) {
        this.createBy = createBy;
        return this;
    }

    @JsonFormat(
            pattern = "yyyy-MM-dd HH:mm:ss"
    )
    public Entity<T> setCreateTime(LocalDateTime createTime) {
        this.createTime = createTime;
        return this;
    }

    public Entity<T> setUpdateBy(T updateBy) {
        this.updateBy = updateBy;
        return this;
    }

    @JsonFormat(
            pattern = "yyyy-MM-dd HH:mm:ss"
    )
    public Entity<T> setUpdateTime(LocalDateTime updateTime) {
        this.updateTime = updateTime;
        return this;
    }

    public Entity<T> setDelFlag(Integer delFlag) {
        this.delFlag = delFlag;
        return this;
    }

    public String toString() {
        String var10000 = super.toString();
        return "Entity(super=" + var10000 + ", id=" + this.getId() + ", createBy=" + this.getCreateBy() + ", createTime=" + this.getCreateTime() + ", updateBy=" + this.getUpdateBy() + ", updateTime=" + this.getUpdateTime() + ", delFlag=" + this.getDelFlag() + ")";
    }
}
